package com.thti.mecool.client.command.result.work;

import com.threeti.mecool.mobile.interfaces.dto.MemoDto;
import com.thti.mecool.client.base.BaseActivity;
import com.thti.mecool.client.base.Cache;
import com.thti.mecool.client.base.HandlerConstant;
import com.thti.mecool.client.command.ICommand;
import com.thti.mecool.client.model.biz.TaskBizImpl;
import com.thti.mecool.client.model.biz.WorkmemoBizImpl;
import com.thti.mecool.client.protocol.work.WorkmemoResult;
import com.thti.mecool.client.service.Protocol;

public class AddWorkmemoCommand implements ICommand{

	@Override
	public void doCommand(Object o) {
		WorkmemoResult workmemoResult=(WorkmemoResult)o;
		if(workmemoResult!=null){
			/**
			 * memo操作代码
			 */
			if(workmemoResult.getStatus()==1){
				BaseActivity.setCurrentMesg(workmemoResult.getMsg());
				BaseActivity.setDataFlag(HandlerConstant.MemoAddCommand);
				WorkmemoBizImpl workmemoBizImpl=new WorkmemoBizImpl(Cache.getmContext());
				MemoDto memoDto=workmemoResult.getAttachment().getMemo();
				String channelName=workmemoBizImpl.findChannelName(workmemoResult.getAttachment().getMemo().getChannelCode());
				memoDto.setChannelName(channelName);
				workmemoBizImpl.save(memoDto);
			}else{
				BaseActivity.setFailName("备忘新增");
				BaseActivity.setCurrentMesg(workmemoResult.getMsg());
				BaseActivity.setDataFlag(HandlerConstant.CommandFail);				
			}
		}
	}

	@Override
	public String getCommandID() {
		
		return Protocol.getAddWorkmemo;
	}

	@Override
	public Class<?> getCommandClass() {
		// TODO Auto-generated method stub
		return WorkmemoResult.class;
	}

}
